package com.huawei.hwCloudJs.core;

import android.content.Context;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;

public class d {
    private static d b = new d();
    private final List<Class<? extends c>> a = new ArrayList();

    public static d a() {
        return b;
    }

    public void a(Context context, String str, String str2, String str3, List<String> list, JSONObject jSONObject) {
        synchronized (this.a) {
            for (Class newInstance : this.a) {
                try {
                    c cVar = (c) newInstance.newInstance();
                    if (list.contains(cVar.getApi())) {
                        cVar.onCompletedConfig(context, str, str2, str3, jSONObject);
                    }
                } catch (InstantiationException e) {
                    Log.e("onCompletedConfig", "InstantiationException");
                } catch (IllegalAccessException e2) {
                    Log.e("onCompletedConfig", "IllegalAccessException");
                }
            }
        }
    }

    public void a(Class<? extends c> cls) {
        synchronized (this.a) {
            this.a.add(cls);
        }
    }

    public void a(String str) {
        synchronized (this.a) {
            for (Class newInstance : this.a) {
                try {
                    ((c) newInstance.newInstance()).onDestroy(str);
                } catch (InstantiationException e) {
                    Log.e("onDestroy", "InstantiationException");
                } catch (IllegalAccessException e2) {
                    Log.e("onDestroy", "IllegalAccessException");
                }
            }
        }
    }
}
